//
//  SearchGroupViewController.m
//  Findif
//
//  Created by Mac on 2019/3/18.
//  Copyright © 2019年 Cicel Chen. All rights reserved.
//

#import "SearchGroupViewController.h"
#import "AddGroupTableViewCell.h"
#import "GroupInfoViewController.h"

@interface SearchGroupViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, weak)UITableView * tableView;

@end

@implementation SearchGroupViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = ColorWithRGB(0xEFF0F1);
    self.title = @"搜索结果";
    
    [self setupUI];
}

- (void)setupUI{
    
    UITableView * tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH) style:UITableViewStylePlain];
    tableView.delegate = self;
    tableView.dataSource = self;
    tableView.backgroundColor = ColorWithRGB(0xEFF0F1);
    tableView.rowHeight = 60 * SCREENH6;
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    tableView.showsVerticalScrollIndicator = NO;
    //    tableView.hidden = YES;
    
    self.tableView = tableView;
    
    [self.tableView registerClass:[AddGroupTableViewCell class] forCellReuseIdentifier:@"SearchGroupTableViewCell"];
    
    //    self.messageTableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
    //
    //        [self updateData];
    //    }];
    
    [self.view addSubview:self.tableView];
    
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    
    return self.modelArray.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    AddGroupTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SearchGroupTableViewCell" forIndexPath:indexPath];
    
    cell.model = self.modelArray[indexPath.row];
    
    return cell;
    
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    GroupModel * model = self.modelArray[indexPath.row];

    NSString * group_jg_gid = [NSString stringWithFormat:@"%@",model.group_jg_gid];
 
    GroupInfoViewController * personVC = [GroupInfoViewController new];

    personVC.group_jg_gid = group_jg_gid;

    [self.navigationController pushViewController:personVC animated:YES];
}
@end
